//
//  LGHotModel.m
//  ifaxian
//
//  Created by ming on 16/12/7.
//  Copyright © 2016年 ming. All rights reserved.
//

#import "LGHotModel.h"
#import "NSString+LGRegularExpressions.h"

@implementation LGHotModel



- (NSString *)imageUrl{
    
    if (_imageUrl.length) {
        
        return _imageUrl;
    }
    _imageUrl = [self.content lg_getImageUrl];
    
    return _imageUrl;
}

- (void)setOriginalImageSize:(CGSize)originalImageSize{
    
    _originalImageSize = originalImageSize;
    /**
     *  等比例缩放
     */
   
    CGFloat imageW = LGScreenW - 2 * LGCommonMargin;
    CGFloat imageH = 0;
    if (originalImageSize.width <= 0) {
        _imageSize = CGSizeMake(0, 0);
        return;
    }
    imageH   = imageW * (originalImageSize.height/originalImageSize.width);
    NSLog(@"%f",imageH);
    
    _imageSize = CGSizeMake(imageW, imageH);
}
- (CGFloat)rowHeght{
    
    if (_rowHeght) {
        return _rowHeght;
    }
    
    _rowHeght += [self.title boundingRectWithSize:CGSizeMake(LGScreenW - 4*LGCommonMargin, MAXFLOAT) options:NSStringDrawingUsesLineFragmentOrigin attributes:@{NSFontAttributeName:[UIFont boldSystemFontOfSize:17]} context:nil].size.height + LGCommonMargin * 3;
    
    _rowHeght += self.imageSize.height;
    return _rowHeght;
    
}
@end
